import React, { Component } from 'react'
import {
  View,
  Text,
  DeviceEventEmitter
} from 'react-native'

import { Modal } from 'antd-mobile'

import color from '../../libs/color'
const alert = Modal.alert

export default class extends Component {
  static navigationOptions = ({ navigation }) => ({
    title: '我的',
    headerStyle:{ backgroundColor: color.theme},
    headerTitleStyle:{ color: 'white', fontSize: 20 }
  })

  constructor(props) {
    super(props)
    this.state = {
      code: ''
    }
  }

  componentDidMount() {
    DeviceEventEmitter.addListener('SCANCODE', (v) => {
      console.log(v)
      this.setState({
        code: v.value
      })
    })
  }

  render() {
    return (
      <View><Text>{this.state.code}</Text></View>
    )
  }
}
